function chooseFriend(e) 
{
	//Check if on hire workers friend selection page
	var friendselection = document.evaluate("//form[@id='app16421175101_friendform']",document,null,9,null).singleNodeValue;
	if (friendselection!=null) {
			alert('on friendselect');
			//This listener should only run once.
			document.removeEventListener("DOMNodeInserted",chooseFriend,false);
			//Pick a random friend and submit the form.
			var hirefriends = document.evaluate("//input[@name='friend_id']",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
			var randomindex=Math.floor(Math.random()*hirefriends.snapshotLength);
			hirefriends.snapshotItem(randomindex).checked = true;
			friendselection.submit();
	}
}

